#ifndef M_LOG_H
#define M_LOG_H

#include <stdio.h>
#include <string.h>

#define M_LOG_ALL "all"
#define M_LOG_TRACE "m_nrf2401,m_cmd_pass"
#define M_LOG_DEBUG "m_nrf2401,m_cmd_pass"
#define M_LOG_INFO  "m_nrf2401,m_cmd_pass"
#define M_LOG_WARN  "m_nrf2401,m_cmd_pass"
#define M_LOG_ERROR "all"

#define m_printf(level, filter, tag, format...) do { if (strstr(filter, tag) != 0 || strstr(filter, M_LOG_ALL) != 0) { printf("[%s][%s]", level, tag);printf(format);}} while(0);

#ifdef M_LOG_TRACE
    #define m_log_t(tag, format...)  m_printf("TRACE", M_LOG_TRACE, tag, format)
#else
    #define m_log_t(tag, format...)
#endif

#ifdef M_LOG_DEBUG
    #define m_log_d(tag, format...)  m_printf("DEBUG", M_LOG_DEBUG, tag, format)
#else
    #define m_log_d(tag, format...)
#endif

#ifdef M_LOG_INFO
    #define m_log_i(tag, format...) m_printf("INFO", M_LOG_INFO, tag, format)
#else
    #define m_log_i(tag, format...)
#endif

#ifdef M_LOG_WARN
    #define m_log_w(tag, format...) m_printf("WARN", M_LOG_WARN, tag, format)
#else
    #define m_log_w(tag, format...)
#endif

#ifdef M_LOG_ERROR
    #define m_log_e(tag, format...) m_printf("ERROR", M_LOG_ERROR, tag, format)
#else
    #define m_log_e(tag, format...)
#endif

#endif